package br.com.linhadotempo.struts2;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

import com.opensymphony.xwork2.ActionSupport;

import br.com.linhadotempo.util.Mensagens;
import br.com.linhadotempo.util.Sessao;
import br.com.linhadotempo.util.Util;

public class LogoffAction extends ActionSupport {

	Mensagens msgs = Mensagens.getInstance();

	@Action(value = "logoff", results = { @Result(name = SUCCESS, location = Util.INDEX_JSP) })
	public String execute() {
		try {
			Sessao.removeMessages();

			Sessao.logoff();

			msgs.setSuccess("Voce efetuou logoff no sistema com sucesso!");
			Sessao.put(Util.MESSAGES, msgs);
			return SUCCESS;
		} catch (Exception e) {
			e.printStackTrace();
			Mensagens.getInstance().tratarExceptions(e);
			return null;
		}
	}

	private static final long serialVersionUID = -2115662208060405960L;
}
